This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Brennan Underwood
brennan@nullsoft.com
*/
//NONPORTABLE
#ifndef _BASEWND_H
#define _BASEWND_H
#define WIN32_LEAN_AND_MEAN
#include "std.h"
#include "common.h"
#include "rootwnd.h"
#include "drag.h"
#include "ptrlist.h"
#include "tlist.h"
#include "named.h"
class BaseWnd;
class TipWnd;
class BltCanvas;
class FilenamePS;
class Canvas;
class CanvasBase;
class Region;
class DragSet;
class VirtualWnd;
using namespace wasabi;
// it is safe to use anything higher than this for your own funky messages
#define BASEWND_NOTIFY_USER NUM_NOTIFY_MESSAGES
#define BASEWND_CURSOR_USERSET -1// window will do own setting
#define BASEWND_CURSOR_POINTER 1
#define BASEWND_CURSOR_NORTHSOUTH 2
#define BASEWND_CURSOR_EASTWEST 3
#define BASEWND_CURSOR_NORTHWEST_SOUTHEAST 4
#define BASEWND_CURSOR_NORTHEAST_SOUTHWEST 5
#define BASEWND_CURSOR_4WAY 6
// Our own defined window messages
#define WM_WA_CONTAINER_TOGGLED WM_USER+0x1338
#define WM_WA_COMPONENT_TOGGLED WM_USER+0x1339
#define WM_WA_RELOAD WM_USER+0x133A
#define WM_WA_GETFBSIZE WM_USER+0x133B
#define WM_WA_CONTEXTMENUNOTIFY WM_USER+0x133D
#define WM_WA_ACTIONNOTIFY WM_USER+0x133E
#define DEFERREDCB_FLUSHPAINT 0x200
#define SYSRGN 4
typedef struct {
RootWnd *origin;
int param1;
int param2;
} defered_callback;
// base class
#define BASEWND_PARENT RootWndI
class COMEXP NOVTABLE BaseWnd :
public RootWndI,
public DragInterface,
public Named {
friend VirtualWnd;
protected:
// override constructor to init your data, but don't create anything yet
BaseWnd();
public:
virtual ~BaseWnd();
//INITIALIZATION
// these actually create the window
// try REALLY hard to not have to override these, and if you do,
// override the second one
virtual int init(RootWnd *parent, int nochild=FALSE);
virtual int init(HINSTANCE hInstance, HWND parent, int nochild=FALSE);// for the root window
virtual int isInited(); // are we post init() ? USE THIS INSTEAD OF gethWnd()==1
// if at all possible put your init stuff in this one, and call up the
// heirarchy BEFORE your code
virtual int onInit();
// use this to return the cursor type to show
virtual int getCursorType(int x, int y);
// WINDOW SIZING/MOVEMENT/CONTROL
virtual int getFontSize() { return 0; }
virtual int setFontSize(int size) { return -1; }
// if you override it, be sure to call up the heirarchy
virtual void resize(int x, int y, int w, int h); // resize yourself
void resize(RECT *r);
void resizeToRect(RECT *r) { resize(r); }//helper
// called after resize happens, return TRUE if you override
virtual int onResize();
void resizeToClient(BaseWnd *wnd); // resize a window to match you
virtual int onPostedMove(); // whenever WM_WINDOWPOSCHANGED happens, use mainly to record positions when moved by the window tracker, avoid using for another prupose, not portable
// move only, no resize
virtual void move(int x, int y);
// puts window on top of its siblings
virtual void moveToFront();
// puts window behind its siblings
virtual void moveToBack();
// fired when a sibbling invalidates a region. you can change the region before returning, use with care, can fuck up everything if not used well
virtual int onSiblingInvalidateRgn(Region *r, RootWnd *who, int who_idx, int my_idx) { return 0; }
// set window's visibility
virtual void setVisible(int show);
virtual void onSetVisible(int show); // override this one
// enable/disable window for input
virtual void enable(int en);
// grab the keyboard focus
virtual void setFocus();
virtual int pointInWnd(POINT *p);
// repaint yourself
virtual void invalidate(); // mark entire window for repainting
virtual void invalidateRect(RECT *r);// mark specific rect for repainting
virtual void invalidateRgn(Region *r);// mark specific rgn for repainting
virtual void invalidateFrom(RootWnd *who); // mark entire window for repainting
virtual void invalidateRectFrom(RECT *r, RootWnd *who);// mark specific rect for repainting
virtual void invalidateRgnFrom(Region *r, RootWnd *who);// mark specific rgn for repainting
virtual void validate(); // unmark the entire window from repainting
virtual void validateRect(RECT *r); // unmark specific rect from repainting
virtual void validateRgn(Region *reg); // unmark specific region from repainting
// no virtual on these please
void deferedInvalidateRgn(Region *h);
void deferedInvalidateRect(RECT *r);
void deferedInvalidate();
void deferedValidateRgn(Region *h);
void deferedValidateRect(RECT *r);
void deferedValidate();
Region *getDeferedInvalidRgn();
int hasVirtualChildren();
virtual int focusNextSibbling(int dochild);
virtual int focusNextVirtualChild(BaseWnd *child);
virtual int focusVirtualChild(RootWnd *child);
private:
virtual void physicalInvalidateRgn(Region *r);
protected:
virtual int ensureVirtualCanvasOk();
virtual void setVirtualCanvas(Canvas *c);
virtual void setRSize(int x, int y, int w, int h);
public:
virtual void repaint(); // repaint right now!
// override this to add decorations
virtual void getClientRect(RECT *);
RECT clientRect(); // helper
virtual void getNonClientRect(RECT *);
RECT nonClientRect(); // helper
virtual void getWindowRect(RECT *); // windows coords in screen system
RECT windowRect(); // helper
virtual void clientToScreen(int *x, int *y); // convenience fn
virtual void screenToClient(int *x, int *y); // convenience fn